Skip to content

Fix JSON logs prettify#4700

Open
joaquimrocha wants to merge 2 commits intokubernetes-sigs:mainfrom
joaquimrocha:fix-logs-prettify
Open

Fix JSON logs prettify#4700
joaquimrocha wants to merge 2 commits intokubernetes-sigs:mainfrom
joaquimrocha:fix-logs-prettify

Conversation

@joaquimrocha
Copy link
Contributor

Summary

This PR fixes #3421 and adds also the prettify/format switches to the deployments' log viewer.

Related Issue

Fixes #3421

Steps to Test

Pods:

  1. Create a simple pod with JSON logs:
apiVersion: v1
kind: Pod
metadata:
  name: json-logger
spec:
  containers:
    - name: logger
      image: busybox
      command: ["/bin/sh", "-c"]
      args:
        - |
          i=0;
          while true; do
            echo "{\"level\":\"info\", \"message\":\"hello from pod\", \"count\": $i}";
            i=$((i+1));
            sleep 1;
          done
  1. Go to the pod's details view and click the logs button: verify there's a prettify/format buttons and they work correctly (maybe the format is not noticeable in this test).

Deployments:

  1. Create a deployment with JSON logs in its pod:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: json-logger-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: json-logger
  template:
    metadata:
      labels:
        app: json-logger
    spec:
      containers:
        - name: logger
          image: busybox
          command: ["/bin/sh", "-c"]
          args:
            - |
              i=0;
              while true; do
                echo "{\"timestamp\":\"$(date -Iseconds)\", \"level\":\"info\", \"message\":\"hello from deployment\", \"count\": $i}";
                i=$((i+1));
                sleep 1;
              done
  1. Go to the deployment's details view and click the logs button: verify there's a prettify/format buttons and they work correctly (maybe the format is not noticeable in this test).

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joaquimrocha

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 13, 2026
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 13, 2026
See issue kubernetes-sigs#3421 that reported that sometimes the JSON logs were not
correctly prettified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Json prettify sometime fails

2 participants